<script setup>
import { ref, computed } from 'vue'
import { injectLanguage } from '../utils/language-store.js'

// 使用语言服务
const { currentLang, t } = injectLanguage()

// 服务流程数据产品分类数据 - 使用computed确保语言切换时自动更新
const categories = computed(() => [
  {
    id: 1,
    name: t('services.categories.category1.title'),
    description: t('services.categories.category1.description'),
    icon: t('services.categories.category1.icon')
  },
  {
    id: 2,
    name: t('services.categories.category2.title'),
    description: t('services.categories.category2.description'),
    icon: t('services.categories.category2.icon')
  },
  {
    id: 3,
    name: t('services.categories.category3.title'),
    description: t('services.categories.category3.description'),
    icon: t('services.categories.category3.icon')
  },
  {
    id: 4,
    name: t('services.categories.category4.title'),
    description: t('services.categories.category4.description'),
    icon: t('services.categories.category4.icon')
  }
])

// 服务流程数据 - 使用computed确保语言切换时自动更新
const processSteps = computed(() => [
  {
    id: 1,
    title: t('services.process.step1.title'),
    description: t('services.process.step1.description')
  },
  {
    id: 2,
    title: t('services.process.step2.title'),
    description: t('services.process.step2.description')
  },
  {
    id: 3,
    title: t('services.process.step3.title'),
    description: t('services.process.step3.description')
  },
  {
    id: 4,
    title: t('services.process.step4.title'),
    description: t('services.process.step4.description')
  },
  {
    id: 5,
    title: t('services.process.step5.title'),
    description: t('services.process.step5.description')
  }
])

// 服务优势数据 - 使用computed确保语言切换时自动更新
const advantages = computed(() => [
  {
    title: t('services.advantages.advantage1.title'),
    description: t('services.advantages.advantage1.description')
  },
  {
    title: t('services.advantages.advantage2.title'),
    description: t('services.advantages.advantage2.description')
  },
  {
    title: t('services.advantages.advantage3.title'),
    description: t('services.advantages.advantage3.description')
  },
  {
    title: t('services.advantages.advantage4.title'),
    description: t('services.advantages.advantage4.description')
  }
])
</script>

<template>
  <div class="services">
    <!-- 产品分类 -->
    <section class="categories">
      <div class="container">
        <h2 v-text="t('services.ourServices')"></h2>
        <div class="category-cards">
          <div 
            class="category-card" 
            v-for="category in categories" 
            :key="category.id"
          >
            <div class="category-icon" v-text="category.icon"></div>
            <h3 v-text="category.name"></h3>
            <p v-text="category.description"></p>
          </div>
        </div>
      </div>
    </section>

    <!-- 服务流程 -->
    <section class="process">
      <div class="container">
        <h2 v-text="t('services.serviceProcess')"></h2>
        <div class="process-steps">
          <div 
            class="process-step" 
            v-for="step in processSteps" 
            :key="step.id"
          >
            <div class="step-number" v-text="step.id"></div>
            <h3 v-text="step.title"></h3>
            <p v-text="step.description"></p>
          </div>
        </div>
      </div>
    </section>

    <!-- 优势特点 -->
    <section class="advantages">
      <div class="container">
        <h2 v-text="t('services.whyChooseUs')"></h2>
        <div class="advantage-cards">
          <div 
            class="advantage-card" 
            v-for="(advantage, index) in advantages" 
            :key="index"
          >
            <h3 v-text="advantage.title"></h3>
            <p v-text="advantage.description"></p>
          </div>
        </div>
      </div>
    </section>
  </div>
</template>

<style scoped>
.services {
  font-family: 'Arial', sans-serif;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 50px 20px;
}

.categories h2, .process h2, .advantages h2 {
  text-align: center;
  font-size: 2.8rem;
  margin-bottom: 3.5rem;
  color: #333;
  position: relative;
}

.categories h2::after, .process h2::after, .advantages h2::after {
  content: '';
  display: block;
  width: 80px;
  height: 4px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  margin: 1rem auto;
  border-radius: 2px;
}

/* 产品分类样式 */
.category-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2.5rem;
  margin-bottom: 5rem;
}

.category-card {
  background: white;
  border-radius: 20px;
  padding: 2.5rem;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  text-align: center;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.category-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.12);
  border-color: rgba(102, 126, 234, 0.2);
}

.category-icon {
  font-size: 3rem;
  margin-bottom: 1.5rem;
}

.category-card h3 {
  font-size: 1.7rem;
  margin-bottom: 1.2rem;
  color: #333;
  font-weight: 700;
}

.category-card p {
  color: #666;
  line-height: 1.7;
  font-size: 1.1rem;
}

/* 服务流程样式 */
.process-steps {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  position: relative;
}

.process-steps::before {
  content: '';
  position: absolute;
  top: 40px;
  left: 50px;
  right: 50px;
  height: 3px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  z-index: 1;
}

.process-step {
  flex: 1;
  min-width: 200px;
  text-align: center;
  position: relative;
  z-index: 2;
  margin-bottom: 2rem;
}

.step-number {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  color: white;
  font-size: 2rem;
  font-weight: bold;
  box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.process-step h3 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: #333;
  font-weight: 700;
}

.process-step p {
  color: #666;
  line-height: 1.7;
  font-size: 1.1rem;
  max-width: 300px;
  margin: 0 auto;
}

/* 优势特点样式 */
.advantage-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2.5rem;
}

.advantage-card {
  background: white;
  border-radius: 20px;
  padding: 2.5rem;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  text-align: center;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.advantage-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.12);
  border-color: rgba(102, 126, 234, 0.2);
}

.advantage-card h3 {
  font-size: 1.7rem;
  margin-bottom: 1.2rem;
  color: #333;
  font-weight: 700;
}

.advantage-card p {
  color: #666;
  line-height: 1.7;
  font-size: 1.1rem;
}

@media (max-width: 768px) {
  .container {
    padding: 3rem 1.5rem;
  }
  
  .categories h2, .process h2, .advantages h2 {
    font-size: 2.2rem;
  }
  
  .category-cards, .advantage-cards {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  
  .process-steps::before {
    display: none;
  }
  
  .process-step {
    min-width: 100%;
    margin-bottom: 3rem;
  }
}
</style>